<?php

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
    private $global;
    public function  __construct($application) {
        parent::__construct($application);
        $this->global = $this->getApplication()->getOption('global');
    }
    protected function _initAdminTranslate(){
        $admin_translate_path = APPLICATION_PATH."/modules/admin/languages/";
        $adminDefaultLang = $this->global['lang']['admindefault'];
      
        try{
                $adminTranslate = new H_Translate(array(
                        'adapter' => 'array',
                        'content' => $admin_translate_path.$adminDefaultLang.".php",
                        'locale'  => $adminDefaultLang
                ));

                $files = scandir($admin_translate_path);
                
                foreach ($files as $file){
                    if (is_file($admin_translate_path.$file)){
                        if ($file != $adminDefaultLang.'.php'){
                            $lang = str_replace(".php", "", $file);
                            $adminTranslate->addTranslation(array(
                                'content' => $admin_translate_path.$file,
                                'locale'  => $lang
                            ));
                        }
                    }
                }

        }catch(Zend_Translate_Exception $e){
            H_E::pDie("Init Translate Error in Admin_Bootstrap".$e->getMessage());
        }

        $adminTranslate->setLocale($adminDefaultLang);        
        $view = Zend_Registry::get("ZEND_VIEW_KEY");
        $view->setTranslate($adminTranslate);
    }
}

